package Test_interface

import (
	"fmt"
)

type Usb interface {
	start()
	stop()
}
type phone struct {

}

func (p *phone)start()  {
	fmt.Println("phone is working")
}
func (p *phone)stop()  {
	fmt.Println("phone is stopping")
}
type came struct {

}

func (c *came)start()  {
	fmt.Println("came is working")
}
func (c *came)stop()  {
	fmt.Println("came is stopping")
}

func operate(u Usb){
	u.start()
	u.stop()
}

func Test2()  {
	operate(&came{})
	var us Usb=&phone{}
	y:=us.(*phone)//在进行类型断言的时候如果接收者是指针类型，那么在进行转换的时候就是*phone
	y.start()
	y.stop()

}
